class VideoElement extends Element {
  constructor(layoutNode, context) {
    super(layoutNode, context)
    this.timer = null
  }

  draw() {
    let { react, ele } = this.layoutNode

    const render = () => {
      this.timer = window.requestAnimationFrame(render)
      this.ctx.clearRect(react.left, react.top, react.width, react.height)
      this.ctx.drawImage(ele, react.left, react.top, react.width, react.height)
      //绘制视频
    }
    ele.addEventListener('play', () => {
      render()
    })
    ele.addEventListener('pause', () => {
      this.stopPlay()
    })
    render()
  }

  stopPlay() {
    window.cancelAnimationFrame(this.timer)
  }
}
